package com.coke.demo.controller;

import com.coke.demo.model.Result;
import com.coke.demo.service.CourseTimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author 19602
 */
@Controller
@RequestMapping("time/")
public class OpenTimeController {

    private CourseTimeService timeService;

    @Autowired
    public void setTimeService(CourseTimeService timeService) {
        this.timeService = timeService;
    }

    @ResponseBody
    @PostMapping("findLabNameByTime")
    @CrossOrigin
    public Result findLabNameByTime(Integer day, String time) {
        List<String> labNames = timeService.findLabNameByTime(day, time);
        if (labNames != null) {
            return new Result("200", "查询成功", labNames);
        } else {
            return new Result("500", "查询失败");
        }
    }

}
